package com.atguigu.principle.singleresponsibility;

/**
 * @Author: yangtao
 * @Description:
 */
public class SingleResponsibility3 {

    public static void main(String[] args) {
    Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.run("汽车");
        vehicle2.runWater("轮船");
        vehicle2.runAir("飞机");
    }
}

//方式三分析 这个修改方法没有对原来的类大的修改,只是新增了方法
//这里虽然没有在类的级别上职责原则
class Vehicle2 {
    public void run(String vehicle) {

        System.out.println(vehicle + "在公路上运行");
    }

    public void runAir(String vehicle) {
        System.out.println(vehicle + "在天空运行");
    }

    public void runWater(String vehicle) {
        System.out.println(vehicle + "在水中运行");
    }
}

